]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
environment: Remove inline import of extensionUtils
authorEvan Welsh <contact@evanwelsh.com>
Tue, 5 Jul 2022 16:11:46 +0000 (12:11 -0400)
committerEvan Welsh <contact@evanwelsh.com>
Wed, 6 Jul 2022 17:40:44 +0000 (13:40 -0400)
The logging function cannot be asynchronous, so move the override
into main.js where ExtensionUtils can be imported at the top level.
Importing ExtensionUtils in environment.js at the top level is not
possible because it would import Main prematurely.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2363>

js/ui/environment.js
js/ui/main.js

index ca27e02fb8361b493a8f5bb885903b245ee9220e..83df7bcce4454695f51c8b40e489b5d96b4d4a40 100644 (file)
@@ -316,27 +316,10 @@ function _easeActorProperty(actor, propName, target, params) {
     transition.connect('stopped', (t, finished) => callback(finished));
 }
 
-function _loggingFunc(...args) {
-    let fields = { 'MESSAGE': args.join(', ') };
-    let domain = "GNOME Shell";
-
-    // If the caller is an extension, add it as metadata
-    let extension = imports.misc.extensionUtils.getCurrentExtension();
-    if (extension != null) {
-        domain = extension.metadata.name;
-        fields['GNOME_SHELL_EXTENSION_UUID'] = extension.uuid;
-        fields['GNOME_SHELL_EXTENSION_NAME'] = extension.metadata.name;
-    }
-
-    GLib.log_structured(domain, GLib.LogLevelFlags.LEVEL_MESSAGE, fields);
-}
-
 function init() {
     // Add some bindings to the global JS namespace
     globalThis.global = Shell.Global.get();
 
-    globalThis.log = _loggingFunc;
-
     globalThis._ = Gettext.gettext;
     globalThis.C_ = Gettext.pgettext;
     globalThis.ngettext = Gettext.ngettext;
index d1f791a9099449301de93f6392401c4dad06a4e6..2d8804aca831bdab5f6f0c6f876c3722af6698d1 100644 (file)
@@ -141,7 +141,27 @@ function _sessionUpdated() {
     }
 }
 
+/**
+ * @param {any...} args a list of values to log
+ */
+function _loggingFunc(...args) {
+    let fields = { 'MESSAGE': args.join(', ') };
+    let domain = 'GNOME Shell';
+
+    // If the caller is an extension, add it as metadata
+    let extension = imports.misc.extensionUtils.getCurrentExtension();
+    if (extension != null) {
+        domain = extension.metadata.name;
+        fields['GNOME_SHELL_EXTENSION_UUID'] = extension.uuid;
+        fields['GNOME_SHELL_EXTENSION_NAME'] = extension.metadata.name;
+    }
+
+    GLib.log_structured(domain, GLib.LogLevelFlags.LEVEL_MESSAGE, fields);
+}
+
 function start() {
+    globalThis.log = _loggingFunc;
+
     // These are here so we don't break compatibility.
     global.logError = globalThis.log;
     global.log = globalThis.log;